.SUFFIXES: .c .o

COMPILE = $(CC) $(CFLAGS)
INC_PATH = -I../common -I/usr/include/fastcommon -I/usr/local/include
LIB_PATH = -L/usr/local/lib -ldb -lfastcommon $(LIBS)
TARGET_PATH = $(TARGET_PREFIX)/bin
CONFIG_PATH = $(TARGET_CONF_PATH)

COMMON_LIB =
SHARED_OBJS = ../common/fdht_global.o \
              ../common/fdht_func.o ../common/fdht_proto.o \
              global.o fdht_io.o db_op.o func.o work_thread.o sync.o \
              db_recovery.o store.o mpool_op.o key_op.o

ALL_OBJS = $(SHARED_OBJS)

ALL_PRGS = fdhtd

all: $(ALL_OBJS) $(ALL_PRGS)
.o:
	$(COMPILE) -o $@ $<  $(SHARED_OBJS) $(COMMON_LIB) $(LIB_PATH) $(INC_PATH)
.c:
	$(COMPILE) -o $@ $<  $(ALL_OBJS) $(COMMON_LIB) $(LIB_PATH) $(INC_PATH)
.c.o:
	$(COMPILE) -c -o $@ $<  $(INC_PATH)
install:
	mkdir -p $(TARGET_PATH)
	mkdir -p $(CONFIG_PATH)
	cp -f $(ALL_PRGS) $(TARGET_PATH)
	if [ ! -f $(CONFIG_PATH)/fdhtd.conf ]; then cp -f ../conf/fdhtd.conf ../conf/fdht_servers.conf $(CONFIG_PATH); fi
clean:
	rm -f $(ALL_OBJS) $(ALL_PRGS)
